/*sum1 = 1 - 1/2 + 2/3 - 3/5 ...
odd item is positive, even item is negative
*/
#include <stdio.h>
double sum1(int n)
{
    int fz,fm,flag,i,temp;
    double item, sum = 0.0;

    
    for(i = 2; i <= n; i++)
    {
        fz = i;
        fm = (i -1) + i;
        item = (double)(fz/fm);
        if(i >=2 && i % 2 == 1 )
        {
            sum += (-1) * item;
            continue;
        }
        
        sum += item;
        
    }
    return sum;
}

int main(void)
{
    int fz,fm,flag,i,n,temp;
    double item, sum;
    printf("Enter a positive integer: ");
    scanf("%d", &n);
    printf("\n");

    sum = sum1(n);
    printf("1 - 1/2 + 2/3 - 3/5 ... the sum of %d item is : %0.2lf\n",n,sum);
    return 0;
}
